package com.zy.qudadid.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zy.lcpassenger.R;
import com.zy.qudadid.model.MyCoupon;
import com.zy.qudadid.presenter.MyCouponPresenter;
import com.zy.qudadid.ui.adapter.base.BaseAdapter;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by liuchao on 2017/4/11.
 */

public class MyCouponAdapter extends BaseAdapter<MyCouponAdapter.ViewHolder, MyCoupon, MyCouponPresenter> {

    public MyCouponAdapter(Context context) {
        super(context);
    }

    @Override
    public int provideItemLayoutId() {
        return R.layout.item_mycoupon;
    }

    @Override
    public ViewHolder createVH(ViewGroup parent, int viewType, View view) {
        return new ViewHolder(view);
    }

    @Override
    public void bindData(ViewHolder holder, int position) {
        MyCoupon item = data.get(position);

        if(item.getTexi().equals("0")){
            if(item.getPricar().equals("0")){
                if(item.getSpecar().equals("0")){

                }else{
                    holder.txtName.setText("专车券");
                    holder.txtType.setText("专车");
                }
            }else{
                holder.txtName.setText("网约车券");
                holder.txtType.setText("网约车");
            }
        }else{
            holder.txtName.setText("出租车券");
            holder.txtType.setText("出租车");
        }

        holder.txtDate.setText("有效期至："+item.getEndtime());
        holder.txtPrice.setText(item.getNum());
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        @Nullable
        @Bind(R.id.txtName)
        TextView txtName;
        @Nullable
        @Bind(R.id.txtDate)
        TextView txtDate;
        @Nullable
        @Bind(R.id.txtType)
        TextView txtType;
        @Nullable
        @Bind(R.id.txtPrice)
        TextView txtPrice;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
